package com.anzhen.interview;


import org.apache.commons.lang3.BooleanUtils;
import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * Created by zhenan on 2017/2/23.
 */
public class BaseType {
    @Test
    public void testByte() {
        //a = a + b 与 a += b 的区别-->+=会自动提升类型
        byte a = 127;
        byte b = 3;
        double i = a + 0.1;
        b += a; // ok
    }
    @Test
    public void testDouble() {
        //精度不能完全表示
        double v = 3 * 0.1;
        double v1 = 0.3;
        System.out.println(v);
        System.out.println(v1);
        System.out.println(v == v1);
    }
    @Test
    public void byteTolang() {
        byte a = 12;
        long b = a;
        System.out.println(b);
    }

    @Test
    public void intTobyte() {
        int a = 129;
        byte b = (byte) a;
        System.out.println(b);
    }

    @Test
    public void byteTString() throws UnsupportedEncodingException {
        String a = "这是一个字符串";
        byte[] bytes = a.getBytes("GBK");
        System.out.println(Arrays.toString(bytes));
        String gbk = new String(bytes, "GBK");
        System.out.println(gbk);
    }

    @Test
    public void test01() {
        Integer a = 127;//
        Integer b = 127;
        Integer c = new Integer(127);
        Integer d = new Integer(127);
        System.out.println(a == b);
        System.out.println(c == d);
        System.out.println(a == c);

    }
    @Test
    public void testBoolean() {

    }

}

class A{
    Boolean aBoolean;

    public Boolean getaBoolean() {
        return aBoolean;
    }

    public void setaBoolean(Boolean aBoolean) {
        this.aBoolean = aBoolean;
    }
}